/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/PassableByReferencePass.php (4202B)
name instanceof Expr || $node->name instanceof Variable) { return; } $name = (string) $node->name; if ($name === 'array_multisort') { return $this->validateArrayMultisort($node); } try { $refl = new \ReflectionFunction($name); } catch (\ReflectionException $e) { // Well, we gave it a shot! return; } foreach ($refl->getParameters() as $key => $param) { if (\array_key_exists($key, $node->args)) { $arg = $node->args[$key]; if ($param->isPassedByReference() && !$this->isPassableByReference($arg)) { throw new FatalErrorException(self::EXCEPTION_MESSAGE, 0, \E_ERROR, null, $node->getLine()); } } } } } private function isPassableByReference(Node $arg): bool { // Unpacked arrays can be passed by reference if ($arg->value instanceof Array_) { return $arg->unpack; } // FuncCall, MethodCall and StaticCall are all PHP _warnings_ not fatal errors, so we'll let // PHP handle those ones :) return $arg->value instanceof ClassConstFetch || $arg->value instanceof PropertyFetch || $arg->value instanceof Variable || $arg->value instanceof FuncCall || $arg->value instanceof MethodCall || $arg->value instanceof StaticCall || $arg->value instanceof ArrayDimFetch; } /** * Because array_multisort has a problematic signature... * * The argument order is all sorts of wonky, and whether something is passed * by reference or not depends on the values of the two arguments before it. * We'll do a good faith attempt at validating this, but err on the side of * permissive. * * This is why you don't design languages where core code and extensions can * implement APIs that wouldn't be possible in userland code. * * @throws FatalErrorException for clearly invalid arguments * * @param Node $node */ private function validateArrayMultisort(Node $node) { $nonPassable = 2; // start with 2 because the first one has to be passable by reference foreach ($node->args as $arg) { if ($this->isPassableByReference($arg)) { $nonPassable = 0; } elseif (++$nonPassable > 2) { // There can be *at most* two non-passable-by-reference args in a row. This is about // as close as we can get to validating the arguments for this function :-/ throw new FatalErrorException(self::EXCEPTION_MESSAGE, 0, \E_ERROR, null, $node->getLine()); } } } }