Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / psy / psysh / src / CodeCleaner / ImplicitReturnPass.php
index 60826712b5c113e007a60ed56303a9b66a20d6d7..06b069780b611f1338034cf3b27d2f4d254c782f 100644 (file)
@@ -14,8 +14,6 @@ namespace Psy\CodeCleaner;
 use PhpParser\Node;
 use PhpParser\Node\Expr;
 use PhpParser\Node\Expr\Exit_;
-use PhpParser\Node\Expr\New_;
-use PhpParser\Node\Name\FullyQualified as FullyQualifiedName;
 use PhpParser\Node\Stmt;
 use PhpParser\Node\Stmt\Break_;
 use PhpParser\Node\Stmt\Expression;
@@ -48,10 +46,10 @@ class ImplicitReturnPass extends CodeCleanerPass
     {
         // If nodes is empty, it can't have a return value.
         if (empty($nodes)) {
-            return [new Return_(new New_(new FullyQualifiedName('Psy\CodeCleaner\NoReturnValue')))];
+            return [new Return_(NoReturnValue::create())];
         }
 
-        $last = end($nodes);
+        $last = \end($nodes);
 
         // Special case a few types of statements to add an implicit return
         // value (even though they technically don't have any return value)
@@ -70,22 +68,22 @@ class ImplicitReturnPass extends CodeCleanerPass
         } elseif ($last instanceof Switch_) {
             foreach ($last->cases as $case) {
                 // only add an implicit return to cases which end in break
-                $caseLast = end($case->stmts);
+                $caseLast = \end($case->stmts);
                 if ($caseLast instanceof Break_) {
-                    $case->stmts = $this->addImplicitReturn(array_slice($case->stmts, 0, -1));
+                    $case->stmts = $this->addImplicitReturn(\array_slice($case->stmts, 0, -1));
                     $case->stmts[] = $caseLast;
                 }
             }
         } elseif ($last instanceof Expr && !($last instanceof Exit_)) {
             // @codeCoverageIgnoreStart
-            $nodes[count($nodes) - 1] = new Return_($last, [
+            $nodes[\count($nodes) - 1] = new Return_($last, [
                 'startLine' => $last->getLine(),
                 'endLine'   => $last->getLine(),
             ]);
         // @codeCoverageIgnoreEnd
         } elseif ($last instanceof Expression && !($last->expr instanceof Exit_)) {
             // For PHP Parser 4.x
-            $nodes[count($nodes) - 1] = new Return_($last->expr, [
+            $nodes[\count($nodes) - 1] = new Return_($last->expr, [
                 'startLine' => $last->getLine(),
                 'endLine'   => $last->getLine(),
             ]);
@@ -104,7 +102,7 @@ class ImplicitReturnPass extends CodeCleanerPass
         // because code outside namespace statements doesn't really work, and
         // there's already an implicit return in the namespace statement anyway.
         if (self::isNonExpressionStmt($last)) {
-            $nodes[] = new Return_(new New_(new FullyQualifiedName('Psy\CodeCleaner\NoReturnValue')));
+            $nodes[] = new Return_(NoReturnValue::create());
         }
 
         return $nodes;