Chris@0: Chris@0: */ Chris@0: class InstanceOfPass extends CodeCleanerPass Chris@0: { Chris@0: const EXCEPTION_MSG = 'instanceof expects an object instance, constant given'; Chris@0: Chris@0: /** Chris@0: * Validate that the instanceof statement does not receive a scalar value or a non-class constant. Chris@0: * Chris@0: * @throws FatalErrorException if a scalar or a non-class constant is given Chris@0: * Chris@0: * @param Node $node Chris@0: */ Chris@0: public function enterNode(Node $node) Chris@0: { Chris@0: if (!$node instanceof Instanceof_) { Chris@0: return; Chris@0: } Chris@0: Chris@0: if (($node->expr instanceof Scalar && !$node->expr instanceof Encapsed) || $node->expr instanceof ConstFetch) { Chris@0: throw new FatalErrorException(self::EXCEPTION_MSG, 0, E_ERROR, null, $node->getLine()); Chris@0: } Chris@0: } Chris@0: }