X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fpsy%2Fpsysh%2Fsrc%2FPsy%2FCodeCleaner%2FAbstractClassPass.php;fp=vendor%2Fpsy%2Fpsysh%2Fsrc%2FPsy%2FCodeCleaner%2FAbstractClassPass.php;h=a6a20c00cda57fd0842e6b917c0cc93c0a9da034;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/psy/psysh/src/Psy/CodeCleaner/AbstractClassPass.php b/vendor/psy/psysh/src/Psy/CodeCleaner/AbstractClassPass.php new file mode 100644 index 000000000..a6a20c00c --- /dev/null +++ b/vendor/psy/psysh/src/Psy/CodeCleaner/AbstractClassPass.php @@ -0,0 +1,69 @@ +class = $node; + $this->abstractMethods = array(); + } elseif ($node instanceof ClassMethod) { + if ($node->isAbstract()) { + $name = sprintf('%s::%s', $this->class->name, $node->name); + $this->abstractMethods[] = $name; + + if ($node->stmts !== null) { + throw new FatalErrorException(sprintf('Abstract function %s cannot contain body', $name)); + } + } + } + } + + /** + * @throws RuntimeException if the node is a non-abstract class with abstract methods + * + * @param Node $node + */ + public function leaveNode(Node $node) + { + if ($node instanceof ClassStmt) { + $count = count($this->abstractMethods); + if ($count > 0 && !$node->isAbstract()) { + throw new FatalErrorException(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', + implode(', ', $this->abstractMethods) + )); + } + } + } +}