/
var
/
www
/
vhosts
/
ihelp.ro
/
httpdocs
/
vendor
/
psy
/
psysh
/
src
/
CodeCleaner
/
/var/www/vhosts/ihelp.ro/httpdocs/vendor/psy/psysh/src/CodeCleaner
mkdir
upload
Name
Size
Mode
Actions
AbstractClassPass.php
2367
0644
edit
dl
rm
AssignThisVariablePass.php
1114
0644
edit
dl
rm
CalledClassPass.php
2736
0644
edit
dl
rm
CallTimePassByReferencePass.php
1607
0644
edit
dl
rm
CodeCleanerPass.php
415
0644
edit
dl
rm
EmptyArrayDimFetchPass.php
2025
0644
edit
dl
rm
ExitPass.php
859
0644
edit
dl
rm
FinalClassPass.php
1781
0644
edit
dl
rm
FunctionContextPass.php
1563
0644
edit
dl
rm
FunctionReturnInWriteContextPass.php
2735
0644
edit
dl
rm
ImplicitReturnPass.php
4237
0644
edit
dl
rm
InstanceOfPass.php
1957
0644
edit
dl
rm
IssetPass.php
1401
0644
edit
dl
rm
LabelContextPass.php
2638
0644
edit
dl
rm
LeavePsyshAlonePass.php
992
0644
edit
dl
rm
ListPass.php
3341
0644
edit
dl
rm
LoopContextPass.php
3694
0644
edit
dl
rm
MagicConstantsPass.php
1068
0644
edit
dl
rm
NamespaceAwarePass.php
1960
0644
edit
dl
rm
NamespacePass.php
2485
0644
edit
dl
rm
NoReturnValue.php
828
0644
edit
dl
rm
PassableByReferencePass.php
4202
0644
edit
dl
rm
RequirePass.php
4665
0644
edit
dl
rm
ReturnTypePass.php
3808
0644
edit
dl
rm
StrictTypesPass.php
2734
0644
edit
dl
rm
UseStatementPass.php
4513
0644
edit
dl
rm
ValidClassNamePass.php
10090
0644
edit
dl
rm
ValidConstructorPass.php
4023
0644
edit
dl
rm
ValidFunctionNamePass.php
2419
0644
edit
dl
rm
Edit:
/var/www/vhosts/ihelp.ro/httpdocs/vendor/psy/psysh/src/CodeCleaner/ValidFunctionNamePass.php
(2419B)
<?php /* * This file is part of Psy Shell. * * (c) 2012-2023 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Psy\CodeCleaner; use PhpParser\Node; use PhpParser\Node\Stmt\Do_; use PhpParser\Node\Stmt\Function_; use PhpParser\Node\Stmt\If_; use PhpParser\Node\Stmt\Switch_; use PhpParser\Node\Stmt\While_; use Psy\Exception\FatalErrorException; /** * Validate that function calls will succeed. * * This pass throws a FatalErrorException rather than letting PHP run * headfirst into a real fatal error and die. */ class ValidFunctionNamePass extends NamespaceAwarePass { private $conditionalScopes = 0; /** * Store newly defined function names on the way in, to allow recursion. * * @throws FatalErrorException if a function is redefined in a non-conditional scope * * @param Node $node * * @return int|Node|null Replacement node (or special return value) */ public function enterNode(Node $node) { parent::enterNode($node); if (self::isConditional($node)) { $this->conditionalScopes++; } elseif ($node instanceof Function_) { $name = $this->getFullyQualifiedName($node->name); // @todo add an "else" here which adds a runtime check for instances where we can't tell // whether a function is being redefined by static analysis alone. if ($this->conditionalScopes === 0) { if (\function_exists($name) || isset($this->currentScope[\strtolower($name)])) { $msg = \sprintf('Cannot redeclare %s()', $name); throw new FatalErrorException($msg, 0, \E_ERROR, null, $node->getLine()); } } $this->currentScope[\strtolower($name)] = true; } } /** * @param Node $node * * @return int|Node|Node[]|null Replacement node (or special return value) */ public function leaveNode(Node $node) { if (self::isConditional($node)) { $this->conditionalScopes--; } } private static function isConditional(Node $node) { return $node instanceof If_ || $node instanceof While_ || $node instanceof Do_ || $node instanceof Switch_; } }
Save
cmd:
run