?????????? ????????? - ??????????????? - /home/agenciai/public_html/cd38d8/Php53.tar
???????
Rector/Variable/ReplaceHttpServerVarsByServerRector.php 0000644 00000003371 15127566667 0017370 0 ustar 00 <?php declare (strict_types=1); namespace Rector\Php53\Rector\Variable; use PhpParser\Node; use PhpParser\Node\Expr\Variable; use Rector\Rector\AbstractRector; use Rector\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector\ReplaceHttpServerVarsByServerRectorTest */ final class ReplaceHttpServerVarsByServerRector extends AbstractRector implements MinPhpVersionInterface { /** * @var array<string, string> */ private const VARIABLE_RENAME_MAP = ['HTTP_SERVER_VARS' => '_SERVER', 'HTTP_GET_VARS' => '_GET', 'HTTP_POST_VARS' => '_POST', 'HTTP_POST_FILES' => '_FILES', 'HTTP_SESSION_VARS' => '_SESSION', 'HTTP_ENV_VARS' => '_ENV', 'HTTP_COOKIE_VARS' => '_COOKIE']; public function provideMinPhpVersion() : int { return PhpVersionFeature::SERVER_VAR; } public function getRuleDefinition() : RuleDefinition { return new RuleDefinition('Rename old $HTTP_* variable names to new replacements', [new CodeSample('$serverVars = $HTTP_SERVER_VARS;', '$serverVars = $_SERVER;')]); } /** * @return array<class-string<Node>> */ public function getNodeTypes() : array { return [Variable::class]; } /** * @param Variable $node */ public function refactor(Node $node) : ?Node { foreach (self::VARIABLE_RENAME_MAP as $oldName => $newName) { if (!$this->isName($node, $oldName)) { continue; } $node->name = $newName; return $node; } return null; } } Rector/Ternary/TernaryToElvisRector.php 0000644 00000002766 15127566667 0014310 0 ustar 00 <?php declare (strict_types=1); namespace Rector\Php53\Rector\Ternary; use PhpParser\Node; use PhpParser\Node\Expr\Ternary; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Rector\AbstractRector; use Rector\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php53\Rector\Ternary\TernaryToElvisRector\TernaryToElvisRectorTest */ final class TernaryToElvisRector extends AbstractRector implements MinPhpVersionInterface { public function getRuleDefinition() : RuleDefinition { return new RuleDefinition('Use ?: instead of ?, where useful', [new CodeSample(<<<'CODE_SAMPLE' function elvis() { $value = $a ? $a : false; } CODE_SAMPLE , <<<'CODE_SAMPLE' function elvis() { $value = $a ?: false; } CODE_SAMPLE )]); } /** * @return array<class-string<Node>> */ public function getNodeTypes() : array { return [Ternary::class]; } /** * @param Ternary $node */ public function refactor(Node $node) : ?Node { if (!$this->nodeComparator->areNodesEqual($node->cond, $node->if)) { return null; } $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); $node->if = null; return $node; } public function provideMinPhpVersion() : int { return PhpVersionFeature::ELVIS_OPERATOR; } } Rector/FuncCall/DirNameFileConstantToDirConstantRector.php 0000644 00000003630 15127566667 0017715 0 ustar 00 <?php declare (strict_types=1); namespace Rector\Php53\Rector\FuncCall; use PhpParser\Node; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Scalar\MagicConst\Dir; use PhpParser\Node\Scalar\MagicConst\File; use Rector\Rector\AbstractRector; use Rector\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector\DirNameFileConstantToDirConstantRectorTest */ final class DirNameFileConstantToDirConstantRector extends AbstractRector implements MinPhpVersionInterface { public function getRuleDefinition() : RuleDefinition { return new RuleDefinition('Convert dirname(__FILE__) to __DIR__', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() { return dirname(__FILE__); } } CODE_SAMPLE , <<<'CODE_SAMPLE' class SomeClass { public function run() { return __DIR__; } } CODE_SAMPLE )]); } /** * @return array<class-string<Node>> */ public function getNodeTypes() : array { return [FuncCall::class]; } /** * @param FuncCall $node */ public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'dirname')) { return null; } if ($node->isFirstClassCallable()) { return null; } if (\count($node->args) !== 1) { return null; } if (!isset($node->getArgs()[0])) { return null; } $firstArg = $node->getArgs()[0]; if (!$firstArg->value instanceof File) { return null; } return new Dir(); } public function provideMinPhpVersion() : int { return PhpVersionFeature::DIR_CONSTANT; } }
| ver. 1.6 |
Github
|
.
| PHP 8.2.30 | ??????????? ?????????: 0 |
proxy
|
phpinfo
|
???????????