|
2865 | 2865 | var info = {}; |
2866 | 2866 | var vis = []; |
2867 | 2867 | for (name in items) { |
| 2868 | + info = items[name]; |
| 2869 | + if (typeof info.inheritedFrom !== 'undefined') { |
| 2870 | + info.declaredLast = info.inheritedFrom; // note that only populated if inherited... |
| 2871 | + // we don't know where it was declared |
| 2872 | + delete info.inheritedFrom; |
| 2873 | + } |
| 2874 | + if (typeof info.overrides !== 'undefined') { |
| 2875 | + info.declaredPrev = info.overrides; |
| 2876 | + delete info.overrides; |
| 2877 | + } |
2868 | 2878 | info = $.extend({ |
2869 | 2879 | declaredLast : null, |
2870 | 2880 | declaredPrev : null, |
2871 | | - objClassName : cfg.objClassName, // used by Properties to determine "isDynamic" |
2872 | | - }, items[name]); |
| 2881 | + }, info); |
2873 | 2882 | vis = typeof info.visibility === 'object' |
2874 | 2883 | ? info.visibility |
2875 | 2884 | : [info.visibility]; |
2876 | | - info.isInherited = info.declaredLast && info.declaredLast !== info.objClassName; |
| 2885 | + info.isInherited = info.declaredLast && info.declaredLast !== cfg.objClassName; |
2877 | 2886 | info.isPrivateAncestor = $.inArray('private', vis) >= 0 && info.isInherited; |
2878 | 2887 | if (info.isPrivateAncestor) { |
2879 | 2888 | info.isInherited = false; |
|
2891 | 2900 | }, |
2892 | 2901 |
|
2893 | 2902 | addAttribs: function ($element, info, cfg) { |
2894 | | - |
| 2903 | + if (cfg.attributeOutput && info.attributes && info.attributes.length) { |
| 2904 | + $element.attr('data-attributes', JSON.stringify(info.attributes)); |
| 2905 | + } |
| 2906 | + if (!info.isInherited && info.declaredPrev) { |
| 2907 | + $element.attr('data-declared-prev', info.declaredPrev); |
| 2908 | + } |
| 2909 | + if (info.isInherited && info.declaredLast) { |
| 2910 | + $element.attr('data-inherited-from', info.declaredLast); |
| 2911 | + } |
2895 | 2912 | }, |
2896 | 2913 |
|
2897 | 2914 | magicMethodInfo: function (abs, methods) { |
|
2925 | 2942 |
|
2926 | 2943 | Cases.prototype.addAttribs = function ($element, info, cfg) { |
2927 | 2944 | $element.addClass('case'); |
2928 | | - if (cfg.attributeOutput && info.attributes && info.attributes.length) { |
2929 | | - $element.attr('data-attributes', JSON.stringify(info.attributes)); |
2930 | | - } |
| 2945 | + sectionPrototype.addAttribs($element, info, cfg); |
2931 | 2946 | }; |
2932 | 2947 |
|
2933 | 2948 | Cases.prototype.dump = function (abs) { |
|
2992 | 3007 | $element.addClass(classname); |
2993 | 3008 | } |
2994 | 3009 | }); |
2995 | | - if (cfg.attributeOutput && info.attributes && info.attributes.length) { |
2996 | | - $element.attr('data-attributes', JSON.stringify(info.attributes)); |
2997 | | - } |
2998 | | - if (info.isInherited || info.isPrivateAncestor) { |
2999 | | - $element.attr('data-inherited-from', info.declaredLast); |
3000 | | - } |
| 3010 | + sectionPrototype.addAttribs($element, info, cfg); |
3001 | 3011 | }; |
3002 | 3012 |
|
3003 | 3013 | Constants.prototype.dump = function (abs) { |
|
3062 | 3072 | $element.addClass(classname); |
3063 | 3073 | } |
3064 | 3074 | }); |
3065 | | - if (cfg.attributeOutput && info.attributes && info.attributes.length) { |
3066 | | - $element.attr('data-attributes', JSON.stringify(info.attributes)); |
3067 | | - } |
| 3075 | + sectionPrototype.addAttribs($element, info, cfg); |
3068 | 3076 | if (info.implements && info.implements.length) { |
3069 | 3077 | $element.attr('data-implements', info.implements); |
3070 | 3078 | } |
3071 | | - if (info.isInherited) { |
3072 | | - $element.attr('data-inherited-from', info.declaredLast); |
3073 | | - } |
3074 | 3079 | if (info.phpDoc && info.phpDoc.deprecated) { |
3075 | 3080 | $element.attr('data-deprecated-desc', info.phpDoc.deprecated[0].desc); |
3076 | 3081 | } |
|
3093 | 3098 | return '' |
3094 | 3099 | } |
3095 | 3100 | if (!cfg.collect) { |
3096 | | - return html |
| 3101 | + return '' |
3097 | 3102 | } |
3098 | 3103 | return '<dt class="methods">' + this.getLabel(abs) + '</dt>' + |
3099 | 3104 | this.magicMethodInfo(abs, ['__call', '__callStatic']) + |
|
3219 | 3224 | Methods.prototype.dumpStaticVars = function (info, cfg) { |
3220 | 3225 | var self = this; |
3221 | 3226 | var html = ''; |
3222 | | - if (!cfg.staticVarOutput || info.staticVars.length < 1) { |
| 3227 | + if (!cfg.staticVarOutput || typeof info.staticVars === 'undefined' || info.staticVars.length < 1) { |
3223 | 3228 | return '' |
3224 | 3229 | } |
3225 | 3230 | html = '<h3>static variables</h3>'; |
|
3249 | 3254 | return label |
3250 | 3255 | }; |
3251 | 3256 |
|
| 3257 | + function versionCompare (v1, v2) { |
| 3258 | + var v1parts = v1.split('.'); |
| 3259 | + var v2parts = v2.split('.'); |
| 3260 | + |
| 3261 | + function isValidPart(x) { |
| 3262 | + return (/^\d+$/).test(x) |
| 3263 | + } |
| 3264 | + |
| 3265 | + if (!v1parts.every(isValidPart) || !v2parts.every(isValidPart)) { |
| 3266 | + return NaN |
| 3267 | + } |
| 3268 | + |
| 3269 | + { |
| 3270 | + while (v1parts.length < v2parts.length) { |
| 3271 | + v1parts.push('0'); |
| 3272 | + } |
| 3273 | + while (v2parts.length < v1parts.length) { |
| 3274 | + v2parts.push('0'); |
| 3275 | + } |
| 3276 | + } |
| 3277 | + |
| 3278 | + { |
| 3279 | + v1parts = v1parts.map(Number); |
| 3280 | + v2parts = v2parts.map(Number); |
| 3281 | + } |
| 3282 | + |
| 3283 | + for (var i = 0; i < v1parts.length; ++i) { |
| 3284 | + if (v2parts.length === i) { |
| 3285 | + return 1 |
| 3286 | + } |
| 3287 | + if (v1parts[i] === v2parts[i]) { |
| 3288 | + continue |
| 3289 | + } else if (v1parts[i] > v2parts[i]) { |
| 3290 | + return 1 |
| 3291 | + } else { |
| 3292 | + return -1 |
| 3293 | + } |
| 3294 | + } |
| 3295 | + |
| 3296 | + if (v1parts.length != v2parts.length) { |
| 3297 | + return -1 |
| 3298 | + } |
| 3299 | + |
| 3300 | + return 0 |
| 3301 | + } |
| 3302 | + |
3252 | 3303 | function Properties (valDumper) { |
3253 | 3304 | this.valDumper = valDumper; |
3254 | 3305 | } |
|
3258 | 3309 | } |
3259 | 3310 |
|
3260 | 3311 | Properties.prototype.dump = function (abs) { |
| 3312 | + var debugVersion = this.valDumper.getRequestInfo().$container.data('meta').debugVersion; |
3261 | 3313 | var cfg = { |
3262 | 3314 | attributeOutput : abs.cfgFlags & this.valDumper.objectDumper.PROP_ATTRIBUTE_OUTPUT, |
| 3315 | + isDynamicSupport : versionCompare(debugVersion, '3.1') >= 0 |
3263 | 3316 | }; |
3264 | 3317 | var label = Object.keys(abs.properties).length |
3265 | 3318 | ? 'properties' |
|
3280 | 3333 | forceShow: info.forceShow, |
3281 | 3334 | isDynamic: info.declaredLast === null && |
3282 | 3335 | info.valueFrom === 'value' && |
3283 | | - info.objclassName !== 'stdClass', |
| 3336 | + cfg.objClassName !== 'stdClass' && |
| 3337 | + cfg.isDynamicSupport, |
3284 | 3338 | isPromoted: info.isPromoted, |
3285 | 3339 | isReadOnly: info.isReadOnly, |
3286 | 3340 | isStatic: info.isStatic, |
|
3293 | 3347 | $element.addClass(classname); |
3294 | 3348 | } |
3295 | 3349 | }); |
3296 | | - if (cfg.attributeOutput && info.attributes && info.attributes.length) { |
3297 | | - $element.attr('data-attributes', JSON.stringify(info.attributes)); |
3298 | | - } |
3299 | | - if (info.isInherited || info.isPrivateAncestor) { |
3300 | | - $element.attr('data-inherited-from', info.declaredLast); |
3301 | | - } |
| 3350 | + sectionPrototype.addAttribs($element, info, cfg); |
3302 | 3351 | }; |
3303 | 3352 |
|
3304 | 3353 | Properties.prototype.dumpInner = function (name, info, cfg) { |
|
3405 | 3454 | var objNew = {}; |
3406 | 3455 | var sortInfo = []; |
3407 | 3456 | var sortVisOrder = ['public', 'magic', 'magic-read', 'magic-write', 'protected', 'private', 'debug']; |
| 3457 | + var vis; |
3408 | 3458 | for (name in obj) { |
3409 | 3459 | if (name === '__construct') { |
3410 | 3460 | sortInfo.push({ |
|
3414 | 3464 | }); |
3415 | 3465 | continue |
3416 | 3466 | } |
| 3467 | + vis = Array.isArray(obj[name].visibility) |
| 3468 | + ? obj[name].visibility[0] |
| 3469 | + : obj[name].visibility; |
3417 | 3470 | sortInfo.push({ |
3418 | 3471 | name: name, |
3419 | 3472 | nameSort: name, |
3420 | | - vis: sortVisOrder.indexOf(obj[name].visibility), |
| 3473 | + vis: sortVisOrder.indexOf(vis), |
3421 | 3474 | }); |
3422 | 3475 | } |
3423 | 3476 | sortBy = sortBy.split(/[,\s]+/); |
|
3451 | 3504 | var html = ''; |
3452 | 3505 | var strClassname = ''; |
3453 | 3506 | var dumpOpts = this.dumper.getDumpOpts(); |
| 3507 | + var debugVersion; |
3454 | 3508 | try { |
3455 | | - abs = this.mergeInherited(abs); |
| 3509 | + if (typeof abs.sort === 'undefined') { |
| 3510 | + abs.sort = 'vis name'; |
| 3511 | + } else if (abs.sort === 'visibility') { |
| 3512 | + debugVersion = this.dumper.getRequestInfo().$container.data('meta').debugVersion; |
| 3513 | + if (versionCompare(debugVersion, '3.2') === -1) { |
| 3514 | + abs.sort = 'vis name'; |
| 3515 | + } |
| 3516 | + } |
3456 | 3517 | if (typeof abs.cfgFlags === 'undefined') { |
3457 | 3518 | abs.cfgFlags = 0x1FFFFFF & ~this.BRIEF; |
3458 | 3519 | } |
| 3520 | + abs = this.mergeInherited(abs); |
| 3521 | + if (typeof abs.implementsList === 'undefined') { |
| 3522 | + // PhpDebugConsole < 3.1 |
| 3523 | + abs.implementsList = abs.implements; |
| 3524 | + } |
3459 | 3525 | strClassname = this.dumpClassname(abs); |
3460 | 3526 | if (abs.isRecursion) { |
3461 | 3527 | return strClassname + |
|
3556 | 3622 | if (!abs.implementsList.length) { |
3557 | 3623 | return '' |
3558 | 3624 | } |
3559 | | - return '<dt class="constants">implements</dt>' + |
| 3625 | + if (typeof abs.interfacesCollapse === 'undefined') { |
| 3626 | + // PhpDebugConsole < 3.2 |
| 3627 | + abs.interfacesCollapse = ['ArrayAccess', 'BackedEnum', 'Countable', 'Iterator', 'IteratorAggregate', 'UnitEnum']; |
| 3628 | + } |
| 3629 | + return '<dt>implements</dt>' + |
3560 | 3630 | '<dd>' + this.buildImplementsTree(abs.implements, abs.interfacesCollapse) + '</dd>' |
3561 | 3631 | }; |
3562 | 3632 |
|
3563 | 3633 | DumpObject.prototype.dumpInner = function (abs) { |
3564 | 3634 | var self = this; |
3565 | 3635 | var html = this.dumpModifiers(abs); |
| 3636 | + if (typeof abs.sectionOrder === 'undefined') { |
| 3637 | + // PhpDebugConsole < 3.2 |
| 3638 | + abs.sectionOrder = ['attributes', 'extends', 'implements', 'constants', 'cases', 'properties', 'methods', 'phpDoc']; |
| 3639 | + } |
3566 | 3640 | abs.sectionOrder.forEach(function (sectionName) { |
3567 | 3641 | html += self.sectionDumpers[sectionName](abs); |
3568 | 3642 | }); |
|
3762 | 3836 | var i = 0; |
3763 | 3837 | var inherited; |
3764 | 3838 | var noInherit = ['attributes', 'cases', 'constants', 'methods', 'properties']; |
| 3839 | + if (abs.classDefinition) { |
| 3840 | + // PhpDebugConsole < 3.2 |
| 3841 | + abs.inheritsFrom = abs.classDefinition; |
| 3842 | + } |
3765 | 3843 | while (abs.inheritsFrom) { |
3766 | 3844 | inherited = this.dumper.getClassDefinition(abs.inheritsFrom); |
3767 | 3845 | if (abs.isRecursion || abs.isExcluded) { |
|
3780 | 3858 | abs.inheritsFrom = inherited.inheritsFrom; |
3781 | 3859 | } |
3782 | 3860 | for (i = 0, count = noInherit.length; i < count; i++) { |
3783 | | - if (Object.keys(abs[noInherit[i]]).length < 2) { |
3784 | | - continue |
| 3861 | + if (typeof abs[noInherit[i]] === 'undefined') { |
| 3862 | + abs[noInherit[i]] = {}; |
3785 | 3863 | } |
3786 | 3864 | abs[noInherit[i]] = sort(abs[noInherit[i]], abs.sort); |
3787 | 3865 | } |
|
4608 | 4686 | dumpOpts.postDump = function (val, dumpOpts) { |
4609 | 4687 | var lis = []; |
4610 | 4688 | if (abs.contentType) { |
4611 | | - lis.push('<li>mime type = <span class="t_string">' + abs.contentType + '</span></li>'); |
| 4689 | + lis.push('<li>mime type = <span class="content-type t_string">' + abs.contentType + '</span></li>'); |
4612 | 4690 | } |
4613 | 4691 | lis.push('<li>size = <span class="t_int">' + abs.strlen + '</span></li>'); |
4614 | 4692 | lis.push(abs.value.length |
4615 | | - ? '<li class="t_string"><span class="binary">' + val + '</span></li>' |
| 4693 | + ? '<li class="t_string">' + val + '</li>' |
4616 | 4694 | : '<li>Binary data not collected</li>'); |
4617 | 4695 | val = '<span class="t_keyword">string</span><span class="text-muted">(binary)</span>' + |
4618 | 4696 | '<ul class="list-unstyled value-container" data-type="' + abs.type + '" data-type-more="binary">' + |
|
4762 | 4840 | } |
4763 | 4841 | if (tagName) { |
4764 | 4842 | dumpOpts.attribs.class.push('t_' + dumpOpts.type); |
4765 | | - if (dumpOpts.typeMore) { |
| 4843 | + if (dumpOpts.typeMore && dumpOpts.typeMore !== 'abstraction') { |
4766 | 4844 | dumpOpts.attribs['data-type-more'] = dumpOpts.typeMore.replace(/\0/g, ''); |
4767 | 4845 | } |
4768 | 4846 | $wrap = $$1('<' + tagName + ' />') |
|
4882 | 4960 | }; |
4883 | 4961 |
|
4884 | 4962 | Dump.prototype.dumpArrayValue = function (key, val, withKey) { |
4885 | | - var classes = ['t_key']; |
| 4963 | + var $key = $$1('<span></span>'); |
| 4964 | + if (withKey === false) { |
| 4965 | + return this.dump(val, { tagName: 'li' }) |
| 4966 | + } |
| 4967 | + $key |
| 4968 | + .addClass('t_key') |
| 4969 | + .html(this.dump(key, { |
| 4970 | + tagName : null |
| 4971 | + })); |
4886 | 4972 | if (/^\d+$/.test(key)) { |
4887 | | - classes.push('t_int'); |
4888 | | - } |
4889 | | - return withKey |
4890 | | - ? '\t<li>' + |
4891 | | - this.dump(key, { |
4892 | | - attribs : { |
4893 | | - class: classes |
4894 | | - } |
4895 | | - }) + |
4896 | | - '<span class="t_operator">=></span>' + |
4897 | | - this.dump(val) + |
4898 | | - '</li>\n' |
4899 | | - : '\t' + this.dump(val, { tagName: 'li' }) + '\n' |
| 4973 | + $key.addClass('t_int'); |
| 4974 | + } |
| 4975 | + return '<li>' + |
| 4976 | + $key[0].outerHTML + |
| 4977 | + '<span class="t_operator">=></span>' + |
| 4978 | + this.dump(val) + |
| 4979 | + '</li>' |
4900 | 4980 | }; |
4901 | 4981 |
|
4902 | 4982 | Dump.prototype.dumpBool = function (val) { |
|
5352 | 5432 | var classDefinition; |
5353 | 5433 | if (isInit) { |
5354 | 5434 | info.$container.data('classDefinitions', {}); |
5355 | | - info.$container.data('meta', metaVals); |
| 5435 | + info.$container.data('meta', $$1.extend({ |
| 5436 | + debugVersion: meta.debugVersion, |
| 5437 | + requestId: meta.requestId, |
| 5438 | + }, metaVals)); |
5356 | 5439 | } |
5357 | 5440 | if (meta.channelNameRoot) { |
5358 | 5441 | info.$container.find('.debug').data('channelNameRoot', meta.channelNameRoot); |
|
0 commit comments