bug #19702 [Debug][HttpKernel][VarDumper] Prepare for committed 7.2 changes (aka "small-bc-breaks") (nicolas-grekas)
This PR was merged into the 2.7 branch.
Discussion
----------
[Debug][HttpKernel][VarDumper] Prepare for committed 7.2 changes (aka "small-bc-breaks")
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | yes
| Tests pass? | yes
| License | MIT
On PHP 7.2:
- `is_object()` is going to return `true` for `__PHP_Incomplete_Class` instances
- `gettype($closed_resource);` returns "resource (closed)"
ping @nikic FYI
see https://travis-ci.org/symfony/symfony/jobs/154114269 for fixed tests (except the one on ClassLoader which is a BC break on 7.1 that should be fixed there IMHO).
Commits
-------
feb2cd0
[Debug][HttpKernel][VarDumper] Prepare for committed 7.2 changes
This commit is contained in:
commit
589b1d4c38
@ -263,7 +263,10 @@ class FlattenException extends LegacyFlattenException
|
|||||||
if (++$count > 1e4) {
|
if (++$count > 1e4) {
|
||||||
return array('array', '*SKIPPED over 10000 entries*');
|
return array('array', '*SKIPPED over 10000 entries*');
|
||||||
}
|
}
|
||||||
if (is_object($value)) {
|
if ($value instanceof \__PHP_Incomplete_Class) {
|
||||||
|
// is_object() returns false on PHP<=7.1
|
||||||
|
$result[$key] = array('incomplete-object', $this->getClassNameFromIncomplete($value));
|
||||||
|
} elseif (is_object($value)) {
|
||||||
$result[$key] = array('object', get_class($value));
|
$result[$key] = array('object', get_class($value));
|
||||||
} elseif (is_array($value)) {
|
} elseif (is_array($value)) {
|
||||||
if ($level > 10) {
|
if ($level > 10) {
|
||||||
@ -277,9 +280,6 @@ class FlattenException extends LegacyFlattenException
|
|||||||
$result[$key] = array('boolean', $value);
|
$result[$key] = array('boolean', $value);
|
||||||
} elseif (is_resource($value)) {
|
} elseif (is_resource($value)) {
|
||||||
$result[$key] = array('resource', get_resource_type($value));
|
$result[$key] = array('resource', get_resource_type($value));
|
||||||
} elseif ($value instanceof \__PHP_Incomplete_Class) {
|
|
||||||
// Special case of object, is_object will return false
|
|
||||||
$result[$key] = array('incomplete-object', $this->getClassNameFromIncomplete($value));
|
|
||||||
} else {
|
} else {
|
||||||
$result[$key] = array('string', (string) $value);
|
$result[$key] = array('string', (string) $value);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,10 @@ class ValueExporter
|
|||||||
*/
|
*/
|
||||||
public function exportValue($value, $depth = 1, $deep = false)
|
public function exportValue($value, $depth = 1, $deep = false)
|
||||||
{
|
{
|
||||||
|
if ($value instanceof \__PHP_Incomplete_Class) {
|
||||||
|
return sprintf('__PHP_Incomplete_Class(%s)', $this->getClassNameFromIncomplete($value));
|
||||||
|
}
|
||||||
|
|
||||||
if (is_object($value)) {
|
if (is_object($value)) {
|
||||||
if ($value instanceof \DateTime || $value instanceof \DateTimeInterface) {
|
if ($value instanceof \DateTime || $value instanceof \DateTimeInterface) {
|
||||||
return sprintf('Object(%s) - %s', get_class($value), $value->format(\DateTime::ISO8601));
|
return sprintf('Object(%s) - %s', get_class($value), $value->format(\DateTime::ISO8601));
|
||||||
@ -35,10 +39,6 @@ class ValueExporter
|
|||||||
return sprintf('Object(%s)', get_class($value));
|
return sprintf('Object(%s)', get_class($value));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($value instanceof \__PHP_Incomplete_Class) {
|
|
||||||
return sprintf('__PHP_Incomplete_Class(%s)', $this->getClassNameFromIncomplete($value));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
if (empty($value)) {
|
if (empty($value)) {
|
||||||
return '[]';
|
return '[]';
|
||||||
|
@ -39,9 +39,12 @@ class CutStub extends Stub
|
|||||||
|
|
||||||
case 'resource':
|
case 'resource':
|
||||||
case 'unknown type':
|
case 'unknown type':
|
||||||
|
case 'resource (closed)':
|
||||||
$this->type = self::TYPE_RESOURCE;
|
$this->type = self::TYPE_RESOURCE;
|
||||||
$this->handle = (int) $value;
|
$this->handle = (int) $value;
|
||||||
$this->class = @get_resource_type($value);
|
if ('Unknown' === $this->class = @get_resource_type($value)) {
|
||||||
|
$this->class = 'Closed';
|
||||||
|
}
|
||||||
$this->cut = -1;
|
$this->cut = -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -183,10 +183,13 @@ class VarCloner extends AbstractCloner
|
|||||||
|
|
||||||
case 'resource':
|
case 'resource':
|
||||||
case 'unknown type':
|
case 'unknown type':
|
||||||
|
case 'resource (closed)':
|
||||||
if (empty($resRefs[$h = (int) $v])) {
|
if (empty($resRefs[$h = (int) $v])) {
|
||||||
$stub = new Stub();
|
$stub = new Stub();
|
||||||
$stub->type = Stub::TYPE_RESOURCE;
|
$stub->type = Stub::TYPE_RESOURCE;
|
||||||
$stub->class = $zval['resource_type'] ?: get_resource_type($v);
|
if ('Unknown' === $stub->class = $zval['resource_type'] ?: @get_resource_type($v)) {
|
||||||
|
$stub->class = 'Closed';
|
||||||
|
}
|
||||||
$stub->value = $v;
|
$stub->value = $v;
|
||||||
$stub->handle = $h;
|
$stub->handle = $h;
|
||||||
$a = $this->castResource($stub, 0 < $i);
|
$a = $this->castResource($stub, 0 < $i);
|
||||||
|
@ -193,7 +193,7 @@ EOTXT
|
|||||||
|
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
<<<EOTXT
|
<<<EOTXT
|
||||||
Unknown resource @{$res}
|
Closed resource @{$res}
|
||||||
|
|
||||||
EOTXT
|
EOTXT
|
||||||
,
|
,
|
||||||
|
Reference in New Issue
Block a user