/var/www/vhosts/ihelp.ro/httpdocs/vendor/psy/psysh/src/CodeCleaner
NameSizeModeActions
AbstractClassPass.php23670644editdlrm
AssignThisVariablePass.php11140644editdlrm
CalledClassPass.php27360644editdlrm
CallTimePassByReferencePass.php16070644editdlrm
CodeCleanerPass.php4150644editdlrm
EmptyArrayDimFetchPass.php20250644editdlrm
ExitPass.php8590644editdlrm
FinalClassPass.php17810644editdlrm
FunctionContextPass.php15630644editdlrm
FunctionReturnInWriteContextPass.php27350644editdlrm
ImplicitReturnPass.php42370644editdlrm
InstanceOfPass.php19570644editdlrm
IssetPass.php14010644editdlrm
LabelContextPass.php26380644editdlrm
LeavePsyshAlonePass.php9920644editdlrm
ListPass.php33410644editdlrm
LoopContextPass.php36940644editdlrm
MagicConstantsPass.php10680644editdlrm
NamespaceAwarePass.php19600644editdlrm
NamespacePass.php24850644editdlrm
NoReturnValue.php8280644editdlrm
PassableByReferencePass.php42020644editdlrm
RequirePass.php46650644editdlrm
ReturnTypePass.php38080644editdlrm
StrictTypesPass.php27340644editdlrm
UseStatementPass.php45130644editdlrm
ValidClassNamePass.php100900644editdlrm
ValidConstructorPass.php40230644editdlrm
ValidFunctionNamePass.php24190644editdlrm
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/psy/psysh/src/CodeCleaner/ValidConstructorPass.php (4023B)
*/ class ValidConstructorPass extends CodeCleanerPass { private $namespace; /** * @return Node[]|null Array of nodes */ 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 * * @return int|Node|null Replacement node (or special return value) */ 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()); } } }