�ɲɾ�����ӯ�����һ��ˣ��������С���˴��ͣ�������P���ҹ��ñ˽��ά�Բ��������˸߸ԣ�������ơ��ҹ��ñ�����ά�Բ���ˡ���˳^�ӣ������ӡ� ���ͯj�ӣ��ƺ���ӣ� ? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!PK;4]"DFF6FuncCall/Utf8DecodeEncodeToMbConvertEncodingRector.phpnu[> */ public function getNodeTypes() : array { return [FuncCall::class]; } /** * @param FuncCall $node */ public function refactor(Node $node) : ?Node { if ($node->isFirstClassCallable()) { return null; } if ($this->isName($node, 'utf8_decode')) { $node->name = new Name('mb_convert_encoding'); $node->args[1] = new Arg(new String_('ISO-8859-1')); return $node; } if ($this->isName($node, 'utf8_encode')) { $node->name = new Name('mb_convert_encoding'); $node->args[1] = new Arg(new String_('UTF-8')); $node->args[2] = new Arg(new String_('ISO-8859-1')); return $node; } return null; } public function provideMinPhpVersion() : int { return PhpVersionFeature::DEPRECATE_UTF8_DECODE_ENCODE_FUNCTION; } } PK;4](`#!i i )New_/FilesystemIteratorSkipDotsRector.phpnu[valueResolver = $valueResolver; } public function getRuleDefinition() : RuleDefinition { return new RuleDefinition('Prior PHP 8.2 FilesystemIterator::SKIP_DOTS was always set and could not be removed, therefore FilesystemIterator::SKIP_DOTS is added in order to keep this behaviour.', [new CodeSample('new FilesystemIterator(__DIR__, FilesystemIterator::KEY_AS_FILENAME);', 'new FilesystemIterator(__DIR__, FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::SKIP_DOTS);')]); } public function getNodeTypes() : array { return [New_::class]; } /** * Add {@see \FilesystemIterator::SKIP_DOTS} to $node when required. * * @param New_ $node */ public function refactor(Node $node) : ?New_ { if ($node->isFirstClassCallable()) { return null; } if (!$this->isObjectType($node->class, new ObjectType('FilesystemIterator'))) { return null; } if (!isset($node->args[1])) { return null; } $flags = $node->getArgs()[1]->value; if ($this->isSkipDotsPresent($flags)) { return null; } $classConstFetch = new ClassConstFetch(new FullyQualified('FilesystemIterator'), 'SKIP_DOTS'); $node->args[1] = new Arg(new BitwiseOr($flags, $classConstFetch)); return $node; } public function provideMinPhpVersion() : int { return PhpVersionFeature::FILESYSTEM_ITERATOR_SKIP_DOTS; } /** * Is the constant {@see \FilesystemIterator::SKIP_DOTS} present within $node? */ private function isSkipDotsPresent(Expr $expr) : bool { while ($expr instanceof BitwiseOr) { if ($this->isSkipDots($expr->right)) { return \true; } $expr = $expr->left; } return $this->isSkipDots($expr); } /** * Tells if $expr is equal to {@see \FilesystemIterator::SKIP_DOTS}. */ private function isSkipDots(Expr $expr) : bool { if (!$expr instanceof ClassConstFetch) { // can be anything return \true; } if (!\defined('FilesystemIterator::SKIP_DOTS')) { return \true; } $value = \constant('FilesystemIterator::SKIP_DOTS'); return $this->valueResolver->isValue($expr, $value); } } PK;4]$H5Encapsed/VariableInStringInterpolationFixerRector.phpnu[> */ public function getNodeTypes() : array { return [Encapsed::class]; } /** * @param Encapsed $node */ public function refactor(Node $node) : ?Node { $oldTokens = $this->file->getOldTokens(); $hasChanged = \false; foreach ($node->parts as $part) { if (!$part instanceof Variable) { continue; } $startTokenPos = $part->getStartTokenPos(); if (!isset($oldTokens[$startTokenPos])) { continue; } if (!\is_array($oldTokens[$startTokenPos])) { continue; } if ($oldTokens[$startTokenPos][1] !== '${') { continue; } $part->setAttribute(AttributeKey::ORIGINAL_NODE, null); $hasChanged = \true; } if (!$hasChanged) { return null; } return $node; } public function provideMinPhpVersion() : int { return PhpVersionFeature::DEPRECATE_VARIABLE_IN_STRING_INTERPOLATION; } } PK;4] .Param/AddSensitiveParameterAttributeRector.phpnu[phpAttributeAnalyzer = $phpAttributeAnalyzer; } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { Assert::allString($configuration[self::SENSITIVE_PARAMETERS] ?? []); $this->sensitiveParameters = (array) ($configuration[self::SENSITIVE_PARAMETERS] ?? []); } public function getNodeTypes() : array { return [Param::class]; } /** * @param Node\Param $node */ public function refactor(Node $node) : ?Param { if (!$this->isNames($node, $this->sensitiveParameters)) { return null; } if ($this->phpAttributeAnalyzer->hasPhpAttribute($node, 'SensitiveParameter')) { return null; } $node->attrGroups[] = new AttributeGroup([new Attribute(new FullyQualified('SensitiveParameter'))]); return $node; } public function getRuleDefinition() : RuleDefinition { return new RuleDefinition('Add SensitiveParameter attribute to method and function configured parameters', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(string $password) { } } CODE_SAMPLE , <<<'CODE_SAMPLE' class SomeClass { public function run(#[\SensitiveParameter] string $password) { } } CODE_SAMPLE , [self::SENSITIVE_PARAMETERS => ['password']])]); } public function provideMinPhpVersion() : int { return PhpVersionFeature::SENSITIVE_PARAMETER_ATTRIBUTE; } } PK;4]~i$$Class_/ReadOnlyClassRector.phpnu[classAnalyzer = $classAnalyzer; $this->visibilityManipulator = $visibilityManipulator; $this->phpAttributeAnalyzer = $phpAttributeAnalyzer; $this->reflectionProvider = $reflectionProvider; } public function getRuleDefinition() : RuleDefinition { return new RuleDefinition('Decorate read-only class with `readonly` attribute', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function __construct( private readonly string $name ) { } } CODE_SAMPLE , <<<'CODE_SAMPLE' final readonly class SomeClass { public function __construct( private string $name ) { } } CODE_SAMPLE )]); } /** * @return array> */ public function getNodeTypes() : array { return [Class_::class]; } /** * @param Class_ $node */ public function refactorWithScope(Node $node, Scope $scope) : ?Node { if ($this->shouldSkip($node, $scope)) { return null; } $this->visibilityManipulator->makeReadonly($node); $constructClassMethod = $node->getMethod(MethodName::CONSTRUCT); if ($constructClassMethod instanceof ClassMethod) { foreach ($constructClassMethod->getParams() as $param) { $this->visibilityManipulator->removeReadonly($param); if ($param->attrGroups !== []) { // invoke reprint with correct newline $param->setAttribute(AttributeKey::ORIGINAL_NODE, null); } } } foreach ($node->getProperties() as $property) { $this->visibilityManipulator->removeReadonly($property); if ($property->attrGroups !== []) { // invoke reprint with correct newline $property->setAttribute(AttributeKey::ORIGINAL_NODE, null); } } if ($node->attrGroups !== []) { // invoke reprint with correct readonly newline $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); } return $node; } public function provideMinPhpVersion() : int { return PhpVersionFeature::READONLY_CLASS; } /** * @return ClassReflection[] */ private function resolveParentClassReflections(Scope $scope) : array { $classReflection = $scope->getClassReflection(); if (!$classReflection instanceof ClassReflection) { return []; } return $classReflection->getParents(); } /** * @param Property[] $properties */ private function hasNonTypedProperty(array $properties) : bool { foreach ($properties as $property) { // properties of readonly class must always have type if ($property->type === null) { return \true; } } return \false; } private function shouldSkip(Class_ $class, Scope $scope) : bool { $classReflection = $scope->getClassReflection(); if (!$classReflection instanceof ClassReflection) { return \true; } if ($this->shouldSkipClass($class)) { return \true; } $parents = $this->resolveParentClassReflections($scope); if (!$class->isFinal()) { return !$this->isExtendsReadonlyClass($parents); } foreach ($parents as $parent) { if (!$parent->isReadOnly()) { return \true; } } $properties = $class->getProperties(); if ($this->hasWritableProperty($properties)) { return \true; } if ($this->hasNonTypedProperty($properties)) { return \true; } if ($this->shouldSkipConsumeTraitProperty($class)) { return \true; } $constructClassMethod = $class->getMethod(MethodName::CONSTRUCT); if (!$constructClassMethod instanceof ClassMethod) { // no __construct means no property promotion, skip if class has no property defined return $properties === []; } $params = $constructClassMethod->getParams(); if ($params === []) { // no params means no property promotion, skip if class has no property defined return $properties === []; } return $this->shouldSkipParams($params); } private function shouldSkipConsumeTraitProperty(Class_ $class) : bool { $traitUses = $class->getTraitUses(); foreach ($traitUses as $traitUse) { foreach ($traitUse->traits as $trait) { $traitName = $trait->toString(); // trait not autoloaded if (!$this->reflectionProvider->hasClass($traitName)) { return \true; } $traitClassReflection = $this->reflectionProvider->getClass($traitName); $nativeReflection = $traitClassReflection->getNativeReflection(); if ($this->hasReadonlyProperty($nativeReflection->getProperties())) { return \true; } } } return \false; } /** * @param ReflectionProperty[] $properties */ private function hasReadonlyProperty(array $properties) : bool { foreach ($properties as $property) { if (!$property->isReadOnly()) { return \true; } } return \false; } /** * @param ClassReflection[] $parents */ private function isExtendsReadonlyClass(array $parents) : bool { foreach ($parents as $parent) { if ($parent->isReadOnly()) { return \true; } } return \false; } /** * @param Property[] $properties */ private function hasWritableProperty(array $properties) : bool { foreach ($properties as $property) { if (!$property->isReadonly()) { return \true; } } return \false; } private function shouldSkipClass(Class_ $class) : bool { // need to have test fixture once feature added to nikic/PHP-Parser if ($this->visibilityManipulator->hasVisibility($class, Visibility::READONLY)) { return \true; } if ($this->classAnalyzer->isAnonymousClass($class)) { return \true; } if ($this->phpAttributeAnalyzer->hasPhpAttribute($class, AttributeName::ALLOW_DYNAMIC_PROPERTIES)) { return \true; } return $class->extends instanceof FullyQualified && !$this->reflectionProvider->hasClass($class->extends->toString()); } /** * @param Param[] $params */ private function shouldSkipParams(array $params) : bool { foreach ($params as $param) { // has non-readonly property promotion if (!$this->visibilityManipulator->hasVisibility($param, Visibility::READONLY) && $param->flags !== 0) { return \true; } // type is missing, invalid syntax if ($param->type === null) { return \true; } } return \false; } } PK`4]b׏%ClassMethod/ArgumentRemoverRector.phpnu[valueResolver = $valueResolver; } public function getRuleDefinition() : RuleDefinition { return new RuleDefinition('Removes defined arguments in defined methods and their calls.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' $someObject = new SomeClass; $someObject->someMethod(true); CODE_SAMPLE , <<<'CODE_SAMPLE' $someObject = new SomeClass; $someObject->someMethod(); CODE_SAMPLE , [new ArgumentRemover('ExampleClass', 'someMethod', 0, [\true])])]); } /** * @return array> */ public function getNodeTypes() : array { return [MethodCall::class, StaticCall::class, ClassMethod::class]; } /** * @param MethodCall|StaticCall|ClassMethod $node * @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Stmt\ClassMethod|null */ public function refactor(Node $node) { $this->hasChanged = \false; foreach ($this->removedArguments as $removedArgument) { if (!$this->isName($node->name, $removedArgument->getMethod())) { continue; } if (!$this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, $removedArgument->getObjectType())) { continue; } $this->processPosition($node, $removedArgument); } if ($this->hasChanged) { return $node; } return null; } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { Assert::allIsAOf($configuration, ArgumentRemover::class); $this->removedArguments = $configuration; } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $node */ private function processPosition($node, ArgumentRemover $argumentRemover) : void { if ($argumentRemover->getValue() === null) { if ($node instanceof MethodCall || $node instanceof StaticCall) { unset($node->args[$argumentRemover->getPosition()]); } else { unset($node->params[$argumentRemover->getPosition()]); } return; } $match = $argumentRemover->getValue(); if (isset($match['name'])) { $this->removeByName($node, $argumentRemover->getPosition(), $match['name']); return; } // only argument specific value can be removed if ($node instanceof ClassMethod) { return; } if (!isset($node->args[$argumentRemover->getPosition()])) { return; } if ($this->isArgumentValueMatch($node->args[$argumentRemover->getPosition()], $match)) { $this->hasChanged = \true; unset($node->args[$argumentRemover->getPosition()]); } } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $node */ private function removeByName($node, int $position, string $name) : void { if ($node instanceof MethodCall || $node instanceof StaticCall) { if (isset($node->args[$position]) && $this->isName($node->args[$position], $name)) { unset($node->args[$position]); } return; } if (!(isset($node->params[$position]) && $this->isName($node->params[$position], $name))) { return; } unset($node->params[$position]); } /** * @param mixed[] $values * @param \PhpParser\Node\Arg|\PhpParser\Node\VariadicPlaceholder $arg */ private function isArgumentValueMatch($arg, array $values) : bool { if (!$arg instanceof Arg) { return \false; } $nodeValue = $this->valueResolver->getValue($arg->value); return \in_array($nodeValue, $values, \true); } } PK`4](22!FuncCall/RemoveFuncCallRector.phpnu[> */ public function getNodeTypes() : array { return [Expression::class]; } /** * @param Expression $node */ public function refactor(Node $node) : ?int { $expr = $node->expr; if (!$expr instanceof FuncCall) { return null; } foreach ($this->removedFunctions as $removedFunction) { if (!$this->isName($expr->name, $removedFunction)) { continue; } return NodeTraverser::REMOVE_NODE; } return null; } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { Assert::allString($configuration); $this->removedFunctions = $configuration; } } PK`4]|H $FuncCall/RemoveFuncCallArgRector.phpnu[> */ public function getNodeTypes() : array { return [FuncCall::class]; } /** * @param FuncCall $node */ public function refactor(Node $node) : ?Node { if ($node->name instanceof Expr) { return null; } $hasChanged = \false; foreach ($this->removedFunctionArguments as $removedFunctionArgument) { if (!$this->isName($node->name, $removedFunctionArgument->getFunction())) { continue; } foreach (\array_keys($node->args) as $position) { if ($removedFunctionArgument->getArgumentPosition() !== $position) { continue; } unset($node->args[$position]); $hasChanged = \true; } } if (!$hasChanged) { return null; } return $node; } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { Assert::allIsAOf($configuration, RemoveFuncCallArg::class); $this->removedFunctionArguments = $configuration; } } PK`4] y!Class_/RemoveInterfacesRector.phpnu[> */ public function getNodeTypes() : array { return [Class_::class]; } /** * @param Class_ $node */ public function refactor(Node $node) : ?Node { if ($node->implements === []) { return null; } $isInterfacesRemoved = \false; foreach ($node->implements as $key => $implement) { if ($this->isNames($implement, $this->interfacesToRemove)) { unset($node->implements[$key]); $isInterfacesRemoved = \true; } } if (!$isInterfacesRemoved) { return null; } return $node; } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { Assert::allString($configuration); /** @var string[] $configuration */ $this->interfacesToRemove = $configuration; } } PK`4]hslClass_/RemoveTraitUseRector.phpnu[> */ public function getNodeTypes() : array { return [Class_::class, Trait_::class]; } /** * @param Class_|Trait_ $node */ public function refactor(Node $node) : ?Node { $hasChanged = \false; foreach ($node->stmts as $key => $stmt) { if (!$stmt instanceof TraitUse) { continue; } foreach ($stmt->traits as $traitKey => $trait) { if (!$this->isNames($trait, $this->traitsToRemove)) { continue; } unset($stmt->traits[$traitKey]); $hasChanged = \true; } // remove empty trait uses if ($stmt->traits === []) { unset($node->stmts[$key]); } } if ($hasChanged) { return $node; } return null; } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { Assert::allString($configuration); $this->traitsToRemove = $configuration; } } PK;4]"DFF6FuncCall/Utf8DecodeEncodeToMbConvertEncodingRector.phpnu[PK;4](`#!i i )New_/FilesystemIteratorSkipDotsRector.phpnu[PK;4]$H5nEncapsed/VariableInStringInterpolationFixerRector.phpnu[PK;4] .VParam/AddSensitiveParameterAttributeRector.phpnu[PK;4]~i$$*Class_/ReadOnlyClassRector.phpnu[PK`4]b׏%NClassMethod/ArgumentRemoverRector.phpnu[PK`4](22!`cFuncCall/RemoveFuncCallRector.phpnu[PK`4]|H $jFuncCall/RemoveFuncCallArgRector.phpnu[PK`4] y!DtClass_/RemoveInterfacesRector.phpnu[PK`4]hslB|Class_/RemoveTraitUseRector.phpnu[PK .