Skip to content

Commit 6b2f2fc

Browse files
committed
align with PHPDebugConsole 3.0b2
1 parent 0c46d76 commit 6b2f2fc

9 files changed

Lines changed: 469 additions & 221 deletions

File tree

src/js/main.js

Lines changed: 234 additions & 110 deletions
Large diffs are not rendered by default.

src/js/main.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js_src/Logger/Dump.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Dump.prototype.checkTimestamp = function (val, abs) {
3030
var date
3131
var dumpOpts
3232
if (typeof abs === 'undefined' || abs.typeMore !== 'timestamp') {
33-
return;
33+
return
3434
}
3535
date = (new Date(val * 1000)).toString()
3636
dumpOpts = this.getDumpOpts()
@@ -68,20 +68,6 @@ Dump.prototype.dump = function (val, opts) {
6868
var tagName
6969
var type // = this.getType(val)
7070
var method // = 'dump' + type[0].ucfirst()
71-
/*
72-
var optsDefault = {
73-
addQuotes: true,
74-
sanitize: true,
75-
visualWhiteSpace: true
76-
}
77-
// console.warn('dump', type, JSON.stringify(val))
78-
if (opts === undefined) {
79-
opts = {}
80-
}
81-
if (tagName === undefined) {
82-
tagName =
83-
}
84-
*/
8571
if (dumpOpts.type === null) {
8672
type = this.getType(val)
8773
dumpOpts.type = type[0]
@@ -276,6 +262,10 @@ Dump.prototype.dumpUndefined = function () {
276262
return ''
277263
}
278264

265+
Dump.prototype.dumpUnknown = function () {
266+
return '<span class="t_unknown">unknown type</span>'
267+
}
268+
279269
Dump.prototype.getDumpOpts = function () {
280270
return dumpOptStack[dumpOptStack.length - 1]
281271
}
@@ -320,6 +310,7 @@ Dump.prototype.getType = function (val) {
320310
}
321311

322312
Dump.prototype.markupIdentifier = function (val, attribs, tag) {
313+
// console.warn('markupIdentifier', val)
323314
var classname = ''
324315
var identifier = ''
325316
var matches = [] // str.match()

src/js_src/Logger/DumpObject.js

Lines changed: 138 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,57 @@ import $ from 'jquery' // external global
22

33
export function DumpObject (dump) {
44
this.dumper = dump
5-
this.COLLECT_METHODS = 2
6-
this.OUTPUT_CONSTANTS = 4
7-
this.OUTPUT_METHODS = 8
8-
this.OUTPUT_METHOD_DESC = 16
9-
this.OUTPUT_ATTRIBUTES_OBJ = 64
10-
this.OUTPUT_ATTRIBUTES_CONST = 256
11-
this.OUTPUT_ATTRIBUTES_PROP = 1024
12-
this.OUTPUT_ATTRIBUTES_METHOD = 4096
13-
this.OUTPUT_ATTRIBUTES_PARAM = 16384
14-
this.OUTPUT_PHPDOC = 65536
5+
6+
// GENERAL
7+
this.PHPDOC_OUTPUT = 2
8+
this.OBJ_ATTRIBUTE_OUTPUT = 8
9+
this.BRIEF = 4194304
10+
11+
// CONSTANTS
12+
this.CONST_COLLECT = 32
13+
this.CONST_OUTPUT = 64
14+
this.CONST_ATTRIBUTE_OUTPUT = 256
15+
16+
// CASE
17+
this.CASE_COLLECT = 512
18+
this.CASE_OUTPUT = 1024
19+
this.CASE_ATTRIBUTE_OUTPUT = 4096
20+
21+
// PROPERTIES
22+
this.PROP_ATTRIBUTE_OUTPUT = 16384
23+
24+
// METHODS
25+
this.METHOD_COLLECT = 32768
26+
this.METHOD_OUTPUT = 65536
27+
this.METHOD_ATTRIBUTE_OUTPUT = 262144
28+
this.METHOD_DESC_OUTPUT = 524288
29+
this.PARAM_ATTRIBUTE_OUTPUT = 2097152
1530
}
1631

1732
DumpObject.prototype.dump = function (abs) {
1833
// console.info('dumpObject', abs)
1934
var html = ''
20-
var outPhpDoc = true
21-
var phpDoc = abs.phpDoc || {}
22-
var strClassName = ''
23-
var title = ((phpDoc.summary || '') + '\n\n' + (phpDoc.desc || '')).trim()
35+
var strClassname = ''
2436
if (typeof abs.cfgFlags === 'undefined') {
25-
abs.cfgFlags = 0x1FFFF
37+
abs.cfgFlags = 0x3FFFFF // 21 bits
2638
}
27-
outPhpDoc = abs.cfgFlags & this.OUTPUT_PHPDOC
28-
strClassName = this.dumper.markupIdentifier(abs.className, {
29-
title: outPhpDoc && title.length ? title : null
30-
})
39+
strClassname = this.dumpClassname(abs)
3140
if (abs.isMaxDepth) {
3241
this.dumper.getDumpOpts().attribs.class.push('max-depth')
3342
}
3443
if (abs.isRecursion) {
35-
return strClassName +
44+
return strClassname +
3645
' <span class="t_recursion">*RECURSION*</span>'
3746
} else if (abs.isExcluded) {
38-
return strClassName +
47+
return strClassname +
3948
' <span class="excluded">(not inspected)</span>'
49+
} else if (abs.cfgFlags & this.BRIEF && abs.implements.indexOf('UnitEnum') > -1) {
50+
return strClassname
4051
}
4152
try {
53+
// console.log('obj abs', abs)
4254
html = this.dumpToString(abs) +
43-
strClassName +
55+
strClassname +
4456
'<dl class="object-inner">' +
4557
(abs.isFinal
4658
? '<dt class="t_modifier_final">final</dt>'
@@ -58,6 +70,7 @@ DumpObject.prototype.dump = function (abs) {
5870
) +
5971
this.dumpAttributes(abs) +
6072
this.dumpConstants(abs) +
73+
this.dumpCases(abs) +
6174
this.dumpProperties(abs, { viaDebugInfo: abs.viaDebugInfo }) +
6275
this.dumpMethods(abs) +
6376
this.dumpPhpDoc(abs) +
@@ -68,6 +81,28 @@ DumpObject.prototype.dump = function (abs) {
6881
return html
6982
}
7083

84+
DumpObject.prototype.dumpClassname = function (abs) {
85+
var phpDoc = abs.phpDoc || {}
86+
var strClassname = abs.className
87+
var title = ((phpDoc.summary || '') + '\n\n' + (phpDoc.desc || '')).trim()
88+
var phpDocOut = abs.cfgFlags & this.PHPDOC_OUTPUT
89+
var $span
90+
if (abs.implements.indexOf('UnitEnum') > -1) {
91+
// strClassname += '::' + abs.properties.name.value
92+
$span = $('<span />', {
93+
class: 't_const',
94+
html: this.dumper.markupIdentifier(strClassname + '::' + abs.properties.name.value)
95+
})
96+
if (title && title.length) {
97+
$span.attr('title', title)
98+
}
99+
return $span[0].outerHTML
100+
}
101+
return this.dumper.markupIdentifier(strClassname, {
102+
title: phpDocOut && title.length ? title : null
103+
})
104+
}
105+
71106
DumpObject.prototype.dumpToString = function (abs) {
72107
// var objToString = ''
73108
var val = ''
@@ -113,7 +148,7 @@ DumpObject.prototype.dumpAttributes = function (abs) {
113148
if (abs.attributes === undefined) {
114149
return ''
115150
}
116-
if ((abs.cfgFlags & this.OUTPUT_ATTRIBUTES_OBJ) !== this.OUTPUT_ATTRIBUTES_OBJ) {
151+
if ((abs.cfgFlags & this.OBJ_ATTRIBUTE_OUTPUT) !== this.OBJ_ATTRIBUTE_OUTPUT) {
117152
return ''
118153
}
119154
// var $dd
@@ -141,30 +176,81 @@ DumpObject.prototype.dumpAttributes = function (abs) {
141176
: ''
142177
}
143178

179+
DumpObject.prototype.dumpCases = function (abs) {
180+
var html = ''
181+
var self = this
182+
var $dd
183+
var attributeOut = abs.cfgFlags & this.CASE_ATTRIBUTE_OUTPUT
184+
var caseCollect = abs.cfgFlags & this.CASE_COLLECT
185+
var caseOut = abs.cfgFlags & this.CASE_OUTPUT
186+
var phpDocOut = abs.cfgFlags & this.PHPDOC_OUTPUT
187+
if (abs.implements.indexOf('UnitEnum') < 0) {
188+
return ''
189+
}
190+
if (!caseOut) {
191+
return ''
192+
}
193+
if (!caseCollect) {
194+
return '<dt class="cases">cases <i>not collected</i></dt>'
195+
}
196+
if (abs.cases.length === 0) {
197+
return '<dt class="cases"><i>no cases!</i></dt>'
198+
}
199+
html = '<dt class="cases">cases</dt>'
200+
$.each(abs.cases, function (key, info) {
201+
var title = phpDocOut
202+
? info.desc
203+
: null
204+
$dd = $('<dd class="case">' +
205+
'<span class="t_identifier">' + key + '</span>' +
206+
(info.value !== null
207+
? ' <span class="t_operator">=</span> ' +
208+
self.dumper.dump(info.value)
209+
: ''
210+
) +
211+
'</dd>'
212+
)
213+
if (title && title.length) {
214+
$dd.find('.t_identifier').attr('title', title)
215+
}
216+
if (attributeOut && info.attributes && info.attributes.length) {
217+
$dd.attr('data-attributes', JSON.stringify(info.attributes))
218+
}
219+
html += $dd[0].outerHTML
220+
})
221+
return html
222+
}
223+
144224
DumpObject.prototype.dumpConstants = function (abs) {
145-
var html = abs.constants && Object.keys(abs.constants).length
146-
? '<dt class="constants">constants</dt>'
147-
: ''
225+
var html = ''
148226
var self = this
149227
var $dd
150-
var outAttributes = abs.cfgFlags & this.OUTPUT_ATTRIBUTES_CONST
151-
var outConstants = abs.cfgFlags & this.OUTPUT_CONSTANTS
152-
var outPhpDoc = abs.cfgFlags & this.OUTPUT_PHPDOC
153-
if (!abs.constants || !outConstants) {
228+
var constCollect = abs.cfgFlags & this.CONST_COLLECT
229+
var attributeOut = abs.cfgFlags & this.CONST_ATTRIBUTE_OUTPUT
230+
var constOut = abs.cfgFlags & this.CONST_OUTPUT
231+
var phpDocOut = abs.cfgFlags & this.PHPDOC_OUTPUT
232+
if (!constOut) {
154233
return ''
155234
}
235+
if (!constCollect) {
236+
return '<dt class="constants">constants <i>not collected</i></dt>'
237+
}
238+
if (!abs.constants) {
239+
return ''
240+
}
241+
html = '<dt class="constants">constants</dt>'
156242
$.each(abs.constants, function (key, info) {
157243
$dd = $('<dd class="constant ' + info.visibility + '">' +
158244
'<span class="t_modifier_' + info.visibility + '">' + info.visibility + '</span> ' +
159245
(info.isFinal
160246
? '<span class="t_modifier_final">final</span> '
161247
: ''
162-
) +
163-
'<span class="t_identifier"' + (outPhpDoc && info.desc ? ' title="' + info.desc.escapeHtml() + '"' : '') + '>' + key + '</span> ' +
248+
) +
249+
'<span class="t_identifier"' + (phpDocOut && info.desc ? ' title="' + info.desc.escapeHtml() + '"' : '') + '>' + key + '</span> ' +
164250
'<span class="t_operator">=</span> ' +
165251
self.dumper.dump(info.value) +
166252
'</dd>')
167-
if (outAttributes && info.attributes && info.attributes.length) {
253+
if (attributeOut && info.attributes && info.attributes.length) {
168254
$dd.attr('data-attributes', JSON.stringify(info.attributes))
169255
}
170256
html += $dd[0].outerHTML
@@ -231,8 +317,8 @@ DumpObject.prototype.dumpProperties = function (abs, meta) {
231317
var label = Object.keys(properties).length
232318
? 'properties'
233319
: 'no properties'
234-
var outPhpDoc = abs.cfgFlags & this.OUTPUT_PHPDOC
235-
var outAttributes = abs.cfgFlags & this.OUTPUT_ATTRIBUTES_PROP
320+
var phpDocOut = abs.cfgFlags & this.PHPDOC_OUTPUT
321+
var attributeOut = abs.cfgFlags & this.PROP_ATTRIBUTE_OUTPUT
236322
var self = this
237323
if (meta.viaDebugInfo) {
238324
label += ' <span class="text-muted">(via __debugInfo)</span>'
@@ -271,7 +357,7 @@ DumpObject.prototype.dumpProperties = function (abs, meta) {
271357
: ''
272358
) +
273359
' <span class="t_identifier"' +
274-
(outPhpDoc && info.desc
360+
(phpDocOut && info.desc
275361
? ' title="' + info.desc.escapeHtml() + '"'
276362
: ''
277363
) +
@@ -283,7 +369,7 @@ DumpObject.prototype.dumpProperties = function (abs, meta) {
283369
) +
284370
'</dd>'
285371
)
286-
if (outAttributes && info.attributes && info.attributes.length) {
372+
if (attributeOut && info.attributes && info.attributes.length) {
287373
$dd.attr('data-attributes', JSON.stringify(info.attributes))
288374
}
289375
if (info.inheritedFrom) {
@@ -301,7 +387,7 @@ DumpObject.prototype.dumpProperties = function (abs, meta) {
301387

302388
DumpObject.prototype.dumpPropertyModifiers = function (info) {
303389
var html = ''
304-
var modifiers = JSON.parse(JSON.stringify(info.visibility));
390+
var modifiers = JSON.parse(JSON.stringify(info.visibility))
305391
if (info.isReadOnly) {
306392
modifiers.push('readonly')
307393
}
@@ -320,15 +406,15 @@ DumpObject.prototype.dumpMethods = function (abs) {
320406
var label = Object.keys(abs.methods).length
321407
? 'methods'
322408
: 'no methods'
323-
var collectMethods = abs.cfgFlags & this.COLLECT_METHODS
324-
var outAttributes = abs.cfgFlags & this.OUTPUT_ATTRIBUTES_METHOD
325-
var outAttributesParam = abs.cfgFlags & this.OUTPUT_ATTRIBUTES_PARAM
326-
var outMethods = abs.cfgFlags & this.OUTPUT_METHODS
327-
var outPhpDoc = abs.cfgFlags & this.OUTPUT_PHPDOC
328-
if (!outMethods) {
409+
var methodCollect = abs.cfgFlags & this.METHOD_COLLECT
410+
var attributeOut = abs.cfgFlags & this.METHOD_ATTRIBUTE_OUTPUT
411+
var paramAttributeOut = abs.cfgFlags & this.PARAM_ATTRIBUTE_OUTPUT
412+
var methodOut = abs.cfgFlags & this.METHOD_OUTPUT
413+
var phpDocOut = abs.cfgFlags & this.PHPDOC_OUTPUT
414+
if (!methodOut) {
329415
return ''
330416
}
331-
if (!collectMethods) {
417+
if (!methodCollect) {
332418
return '<dt class="methdos">methods not collected</dt>'
333419
}
334420
html = '<dt class="methods">' + label + '</dt>'
@@ -337,8 +423,8 @@ DumpObject.prototype.dumpMethods = function (abs) {
337423
var $dd = $('<dd class="method"></dd>').addClass(info.visibility)
338424
var modifiers = []
339425
var paramStr = self.dumpMethodParams(info.params, {
340-
outAttributes: outAttributesParam,
341-
outPhpDoc: outPhpDoc
426+
attributeOut: paramAttributeOut,
427+
phpDocOut: phpDocOut
342428
})
343429
var returnType = ''
344430
if (info.isFinal) {
@@ -351,7 +437,7 @@ DumpObject.prototype.dumpMethods = function (abs) {
351437
}
352438
if (info.return && info.return.type) {
353439
returnType = ' <span class="t_type"' +
354-
(outPhpDoc && info.return.desc !== null
440+
(phpDocOut && info.return.desc !== null
355441
? ' title="' + info.return.desc.escapeHtml() + '"'
356442
: ''
357443
) +
@@ -361,7 +447,7 @@ DumpObject.prototype.dumpMethods = function (abs) {
361447
modifiers.join(' ') +
362448
returnType +
363449
' <span class="t_identifier"' +
364-
(outPhpDoc && info.phpDoc && info.phpDoc.summary !== null
450+
(phpDocOut && info.phpDoc && info.phpDoc.summary !== null
365451
? ' title="' + info.phpDoc.summary.escapeHtml() + '"'
366452
: ''
367453
) +
@@ -374,7 +460,7 @@ DumpObject.prototype.dumpMethods = function (abs) {
374460
'</dd>'
375461
)
376462

377-
if (outAttributes && info.attributes && info.attributes.length) {
463+
if (attributeOut && info.attributes && info.attributes.length) {
378464
$dd.attr('data-attributes', JSON.stringify(info.attributes))
379465
}
380466
if (info.implements && info.implements.length) {
@@ -412,14 +498,14 @@ DumpObject.prototype.dumpMethodParams = function (params, opts) {
412498
if (info.isPromoted) {
413499
$param.addClass('isPromoted')
414500
}
415-
if (opts.outAttributes && info.attributes && info.attributes.length) {
501+
if (opts.attributeOut && info.attributes && info.attributes.length) {
416502
$param.attr('data-attributes', JSON.stringify(info.attributes))
417503
}
418504
if (typeof info.type === 'string') {
419505
$param.append('<span class="t_type">' + info.type + '</span> ')
420506
}
421507
$param.append('<span class="t_parameter-name"' +
422-
(opts.outPhpDoc && info.desc !== null
508+
(opts.phpDocOut && info.desc !== null
423509
? ' title="' + info.desc.escapeHtml().replace('\n', ' ') + '"'
424510
: ''
425511
) + '>' + info.name.escapeHtml() + '</span>')

0 commit comments

Comments
 (0)