Yaffs site version 1.1
[yaffs-website] / vendor / psy / psysh / src / Psy / CodeCleaner / AbstractClassPass.php
index a6a20c00cda57fd0842e6b917c0cc93c0a9da034..fad6d8f5638465d92c9fd4278fbd0522387fea0f 100644 (file)
@@ -12,7 +12,7 @@
 namespace Psy\CodeCleaner;
 
 use PhpParser\Node;
-use PhpParser\Node\Stmt\Class_ as ClassStmt;
+use PhpParser\Node\Stmt\Class_;
 use PhpParser\Node\Stmt\ClassMethod;
 use Psy\Exception\FatalErrorException;
 
@@ -31,7 +31,7 @@ class AbstractClassPass extends CodeCleanerPass
      */
     public function enterNode(Node $node)
     {
-        if ($node instanceof ClassStmt) {
+        if ($node instanceof Class_) {
             $this->class = $node;
             $this->abstractMethods = array();
         } elseif ($node instanceof ClassMethod) {
@@ -40,7 +40,8 @@ class AbstractClassPass extends CodeCleanerPass
                 $this->abstractMethods[] = $name;
 
                 if ($node->stmts !== null) {
-                    throw new FatalErrorException(sprintf('Abstract function %s cannot contain body', $name));
+                    $msg = sprintf('Abstract function %s cannot contain body', $name);
+                    throw new FatalErrorException($msg, 0, E_ERROR, null, $node->getLine());
                 }
             }
         }
@@ -53,16 +54,17 @@ class AbstractClassPass extends CodeCleanerPass
      */
     public function leaveNode(Node $node)
     {
-        if ($node instanceof ClassStmt) {
+        if ($node instanceof Class_) {
             $count = count($this->abstractMethods);
             if ($count > 0 && !$node->isAbstract()) {
-                throw new FatalErrorException(sprintf(
+                $msg = sprintf(
                     'Class %s contains %d abstract method%s must therefore be declared abstract or implement the remaining methods (%s)',
                     $node->name,
                     $count,
-                    ($count === 0) ? '' : 's',
+                    ($count === 1) ? '' : 's',
                     implode(', ', $this->abstractMethods)
-                ));
+                );
+                throw new FatalErrorException($msg, 0, E_ERROR, null, $node->getLine());
             }
         }
     }