X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fpsy%2Fpsysh%2Fsrc%2FPsy%2FCodeCleaner%2FInstanceOfPass.php;fp=vendor%2Fpsy%2Fpsysh%2Fsrc%2FPsy%2FCodeCleaner%2FInstanceOfPass.php;h=7c2ae7bb3c78696ee3962222f015798d31c5ee8c;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/vendor/psy/psysh/src/Psy/CodeCleaner/InstanceOfPass.php b/vendor/psy/psysh/src/Psy/CodeCleaner/InstanceOfPass.php new file mode 100644 index 000000000..7c2ae7bb3 --- /dev/null +++ b/vendor/psy/psysh/src/Psy/CodeCleaner/InstanceOfPass.php @@ -0,0 +1,45 @@ + + */ +class InstanceOfPass extends CodeCleanerPass +{ + /** + * Validate that the instanceof statement does not receive a scalar value or a non-class constant. + * + * @throws FatalErrorException if a scalar or a non-class constant is given + * + * @param Node $node + */ + public function enterNode(Node $node) + { + if (!$node instanceof InstanceofStmt) { + return; + } + + if (($node->expr instanceof Scalar && !$node->expr instanceof Encapsed) || $node->expr instanceof ConstFetch) { + throw new FatalErrorException('instanceof expects an object instance, constant given'); + } + } +}