/var/www/flurhymez/vendor/psy/psysh/src/CodeCleaner
NameSizeModeActions
AbstractClassPass.php22020644editdlrm
AssignThisVariablePass.php10350644editdlrm
CalledClassPass.php23870644editdlrm
CallTimePassByReferencePass.php13920644editdlrm
CodeCleanerPass.php4150644editdlrm
EmptyArrayDimFetchPass.php12830644editdlrm
ExitPass.php7730644editdlrm
FinalClassPass.php16670644editdlrm
FunctionContextPass.php13400644editdlrm
FunctionReturnInWriteContextPass.php25010644editdlrm
ImplicitReturnPass.php42400644editdlrm
InstanceOfPass.php18780644editdlrm
IssetPass.php13220644editdlrm
LabelContextPass.php23570644editdlrm
LeavePsyshAlonePass.php9130644editdlrm
ListPass.php32830644editdlrm
LoopContextPass.php34800644editdlrm
MagicConstantsPass.php10680644editdlrm
NamespaceAwarePass.php18530644editdlrm
NamespacePass.php24160644editdlrm
NoReturnValue.php8700644editdlrm
PassableByReferencePass.php41170644editdlrm
RequirePass.php45650644editdlrm
ReturnTypePass.php34650644editdlrm
StrictTypesPass.php27060644editdlrm
UseStatementPass.php43360644editdlrm
ValidClassNamePass.php124330644editdlrm
ValidConstantPass.php32030644editdlrm
ValidConstructorPass.php38860644editdlrm
ValidFunctionNamePass.php32380644editdlrm
Edit: /var/www/flurhymez/vendor/psy/psysh/src/CodeCleaner/ValidConstructorPass.php (3886B)
*/ class ValidConstructorPass extends CodeCleanerPass { private $namespace; public function beforeTraverse(array $nodes) { $this->namespace = []; } /** * Validate that the constructor is not static and does not have a return type. * * @throws FatalErrorException the constructor function is static * @throws FatalErrorException the constructor function has a return type * * @param Node $node */ public function enterNode(Node $node) { if ($node instanceof Namespace_) { $this->namespace = isset($node->name) ? $node->name->parts : []; } elseif ($node instanceof Class_) { $constructor = null; foreach ($node->stmts as $stmt) { if ($stmt instanceof ClassMethod) { // If we find a new-style constructor, no need to look for the old-style if ('__construct' === \strtolower($stmt->name)) { $this->validateConstructor($stmt, $node); return; } // We found a possible old-style constructor (unless there is also a __construct method) if (empty($this->namespace) && \strtolower($node->name) === \strtolower($stmt->name)) { $constructor = $stmt; } } } if ($constructor) { $this->validateConstructor($constructor, $node); } } } /** * @throws FatalErrorException the constructor function is static * @throws FatalErrorException the constructor function has a return type * * @param Node $constructor * @param Node $classNode */ private function validateConstructor(Node $constructor, Node $classNode) { if ($constructor->isStatic()) { // For PHP Parser 4.x $className = $classNode->name instanceof Identifier ? $classNode->name->toString() : $classNode->name; $msg = \sprintf( 'Constructor %s::%s() cannot be static', \implode('\\', \array_merge($this->namespace, (array) $className)), $constructor->name ); throw new FatalErrorException($msg, 0, \E_ERROR, null, $classNode->getLine()); } if (\method_exists($constructor, 'getReturnType') && $constructor->getReturnType()) { // For PHP Parser 4.x $className = $classNode->name instanceof Identifier ? $classNode->name->toString() : $classNode->name; $msg = \sprintf( 'Constructor %s::%s() cannot declare a return type', \implode('\\', \array_merge($this->namespace, (array) $className)), $constructor->name ); throw new FatalErrorException($msg, 0, \E_ERROR, null, $classNode->getLine()); } } }