diff vendor/symfony/var-dumper/Caster/ReflectionCaster.php @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children
line wrap: on
line diff
--- a/vendor/symfony/var-dumper/Caster/ReflectionCaster.php	Thu Feb 28 11:14:44 2019 +0000
+++ b/vendor/symfony/var-dumper/Caster/ReflectionCaster.php	Thu Feb 28 13:11:55 2019 +0000
@@ -20,7 +20,7 @@
  */
 class ReflectionCaster
 {
-    private static $extraMap = array(
+    private static $extraMap = [
         'docComment' => 'getDocComment',
         'extension' => 'getExtensionName',
         'isDisabled' => 'isDisabled',
@@ -29,7 +29,7 @@
         'isUserDefined' => 'isUserDefined',
         'isGenerator' => 'isGenerator',
         'isVariadic' => 'isVariadic',
-    );
+    ];
 
     public static function castClosure(\Closure $c, array $a, Stub $stub, $isNested, $filter = 0)
     {
@@ -39,11 +39,16 @@
         $stub->class = 'Closure'; // HHVM generates unique class names for closures
         $a = static::castFunctionAbstract($c, $a, $stub, $isNested, $filter);
 
+        if (false === strpos($c->name, '{closure}')) {
+            $stub->class = isset($a[$prefix.'class']) ? $a[$prefix.'class']->value.'::'.$c->name : $c->name;
+            unset($a[$prefix.'class']);
+        }
+
         if (isset($a[$prefix.'parameters'])) {
             foreach ($a[$prefix.'parameters']->value as &$v) {
                 $param = $v;
-                $v = new EnumStub(array());
-                foreach (static::castParameter($param, array(), $stub, true) as $k => $param) {
+                $v = new EnumStub([]);
+                foreach (static::castParameter($param, [], $stub, true) as $k => $param) {
                     if ("\0" === $k[0]) {
                         $v->value[substr($k, 3)] = $param;
                     }
@@ -85,11 +90,11 @@
     {
         $prefix = Caster::PREFIX_VIRTUAL;
 
-        $a += array(
+        $a += [
             $prefix.'name' => $c instanceof \ReflectionNamedType ? $c->getName() : $c->__toString(),
             $prefix.'allowsNull' => $c->allowsNull(),
             $prefix.'isBuiltin' => $c->isBuiltin(),
-        );
+        ];
 
         return $a;
     }
@@ -102,28 +107,28 @@
             $a[$prefix.'this'] = new CutStub($c->getThis());
         }
         $function = $c->getFunction();
-        $frame = array(
+        $frame = [
             'class' => isset($function->class) ? $function->class : null,
             'type' => isset($function->class) ? ($function->isStatic() ? '::' : '->') : null,
             'function' => $function->name,
             'file' => $c->getExecutingFile(),
             'line' => $c->getExecutingLine(),
-        );
+        ];
         if ($trace = $c->getTrace(DEBUG_BACKTRACE_IGNORE_ARGS)) {
             $function = new \ReflectionGenerator($c->getExecutingGenerator());
-            array_unshift($trace, array(
+            array_unshift($trace, [
                 'function' => 'yield',
                 'file' => $function->getExecutingFile(),
                 'line' => $function->getExecutingLine() - 1,
-            ));
+            ]);
             $trace[] = $frame;
             $a[$prefix.'trace'] = new TraceStub($trace, false, 0, -1, -1);
         } else {
             $function = new FrameStub($frame, false, true);
-            $function = ExceptionCaster::castFrameStub($function, array(), $function, true);
-            $a[$prefix.'executing'] = new EnumStub(array(
+            $function = ExceptionCaster::castFrameStub($function, [], $function, true);
+            $a[$prefix.'executing'] = new EnumStub([
                 "\0~separator= \0".$frame['class'].$frame['type'].$frame['function'].'()' => $function[$prefix.'src'],
-            ));
+            ]);
         }
 
         $a[Caster::PREFIX_VIRTUAL.'closed'] = false;
@@ -139,11 +144,11 @@
             $a[$prefix.'modifiers'] = implode(' ', $n);
         }
 
-        self::addMap($a, $c, array(
+        self::addMap($a, $c, [
             'extends' => 'getParentClass',
             'implements' => 'getInterfaceNames',
             'constants' => 'getConstants',
-        ));
+        ]);
 
         foreach ($c->getProperties() as $n) {
             $a[$prefix.'properties'][$n->name] = $n;
@@ -164,17 +169,17 @@
     {
         $prefix = Caster::PREFIX_VIRTUAL;
 
-        self::addMap($a, $c, array(
+        self::addMap($a, $c, [
             'returnsReference' => 'returnsReference',
             'returnType' => 'getReturnType',
             'class' => 'getClosureScopeClass',
             'this' => 'getClosureThis',
-        ));
+        ]);
 
         if (isset($a[$prefix.'returnType'])) {
             $v = $a[$prefix.'returnType'];
             $v = $v instanceof \ReflectionNamedType ? $v->getName() : $v->__toString();
-            $a[$prefix.'returnType'] = new ClassStub($a[$prefix.'returnType']->allowsNull() ? '?'.$v : $v, array(class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', ''));
+            $a[$prefix.'returnType'] = new ClassStub($a[$prefix.'returnType']->allowsNull() ? '?'.$v : $v, [class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', '']);
         }
         if (isset($a[$prefix.'class'])) {
             $a[$prefix.'class'] = new ClassStub($a[$prefix.'class']);
@@ -199,7 +204,7 @@
 
         if ($v = $c->getStaticVariables()) {
             foreach ($v as $k => &$v) {
-                if (is_object($v)) {
+                if (\is_object($v)) {
                     $a[$prefix.'use']['$'.$k] = new CutStub($v);
                 } else {
                     $a[$prefix.'use']['$'.$k] = &$v;
@@ -233,12 +238,12 @@
         // Added by HHVM
         unset($a['info']);
 
-        self::addMap($a, $c, array(
+        self::addMap($a, $c, [
             'position' => 'getPosition',
             'isVariadic' => 'isVariadic',
             'byReference' => 'isPassedByReference',
             'allowsNull' => 'allowsNull',
-        ));
+        ]);
 
         if (method_exists($c, 'getType')) {
             if ($v = $c->getType()) {
@@ -250,7 +255,7 @@
 
         if (isset($a[$prefix.'typeHint'])) {
             $v = $a[$prefix.'typeHint'];
-            $a[$prefix.'typeHint'] = new ClassStub($v, array(class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', ''));
+            $a[$prefix.'typeHint'] = new ClassStub($v, [class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', '']);
         } else {
             unset($a[$prefix.'allowsNull']);
         }
@@ -283,7 +288,7 @@
 
     public static function castExtension(\ReflectionExtension $c, array $a, Stub $stub, $isNested)
     {
-        self::addMap($a, $c, array(
+        self::addMap($a, $c, [
             'version' => 'getVersion',
             'dependencies' => 'getDependencies',
             'iniEntries' => 'getIniEntries',
@@ -292,26 +297,26 @@
             'constants' => 'getConstants',
             'functions' => 'getFunctions',
             'classes' => 'getClasses',
-        ));
+        ]);
 
         return $a;
     }
 
     public static function castZendExtension(\ReflectionZendExtension $c, array $a, Stub $stub, $isNested)
     {
-        self::addMap($a, $c, array(
+        self::addMap($a, $c, [
             'version' => 'getVersion',
             'author' => 'getAuthor',
             'copyright' => 'getCopyright',
             'url' => 'getURL',
-        ));
+        ]);
 
         return $a;
     }
 
     private static function addExtra(&$a, \Reflector $c)
     {
-        $x = isset($a[Caster::PREFIX_VIRTUAL.'extra']) ? $a[Caster::PREFIX_VIRTUAL.'extra']->value : array();
+        $x = isset($a[Caster::PREFIX_VIRTUAL.'extra']) ? $a[Caster::PREFIX_VIRTUAL.'extra']->value : [];
 
         if (method_exists($c, 'getFileName') && $m = $c->getFileName()) {
             $x['file'] = new LinkStub($m, $c->getStartLine());